Path: blob/master/Part 3 - Classification/Random Forest/[Python] Random Forest.ipynb
1009 views
Random Forest
Data preprocessing
Fitting Random Forest Classifier to the Training set
Predicting the Test set results
Making the Confusion Matrix
classifier made 47 + 22 = 69 correct prediction and 5 + 6 = 11 incoreect predictions.
Visualising the Training set results
Visualising the Test set results
Things to remmember while making Random Forest classifier:
For each user there are 10 trees making a prediction whether the user buys the SUV or not. The there is a vote of the majority prediction. If there is more yes, then the region is green and if there is more no, then the region is red.
Normally it overfits the data. As you can see in above training set, it tries to catch all the red dots which is in the green region, if we look carefully. Also from the test set we can see that some green points were in the red region on the top right.
There is no need to Scale the features as Random Forest does not depends on Euclidean distance. We are using Feature Scaling here just to get a plot with better resolution. For example if in above case you ommit scaling then while ploting you will get MemoryError.